package com.springboot.frame;

import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.concurrent.Future;

/**
 * @author liheng
 * @ClassName AsyncThread
 * @Description
 * @date 2021-04-26 15:00
 */
@Component
public class AsyncThreadExecute {
    /**
     * 指定线程池
     * @param baseAdapt
     * @param <T>
     * @param <Base>
     * @return
     */
    @Async("taskAsyncPool")
    public <T, Base> Future<T> getT(BaseAdapt<T, Base> baseAdapt) {
        return new AsyncResult<>(baseAdapt.getT());
    }

    @Async("taskAsyncPool")
    public <T, Base> Future<List<T>> list(BaseAdapt<T, Base> baseAdapt) {
        return new AsyncResult<>(baseAdapt.list());
    }

}
